package ar.edu.itba.pod.legajo47573.messages;

import java.io.Serializable;

import org.jgroups.Address;

import ar.edu.itba.pod.api.Signal;

public class OwnerBackupSignal implements Serializable{

	private Signal signal;
	private Address owner;
	private Address backup;
	
	public OwnerBackupSignal(Signal signal, Address owner, Address backup){
		this.signal = signal;
		this.owner = owner;
		this.backup = backup;
	}
	
	public Signal getSignal() {
		return signal;
	}
	
	public Address getOwner() {
		return owner;
	}
	
	public Address getBackup() {
		return backup;
	}
	
	public void setOwner(Address owner) {
		this.owner = owner;
	}
	
	public void setBackup(Address backup) {
		this.backup = backup;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((signal == null) ? 0 : signal.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OwnerBackupSignal other = (OwnerBackupSignal) obj;
		if (signal == null) {
			if (other.signal != null)
				return false;
		} else if (!signal.equals(other.signal))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "OWN: " + owner + "/" + "BACK: " + backup + "/" + "SIG: " + signal;
	}
}
